home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / TSPA3460 / TSUNTENV.INT < prev    next >
Text File  |  1994-08-16  |  3KB  |  88 lines

  1. (*
  2. Timo Salmi UNiT ENV
  3. A Turbo Pascal unit of file environment handling routines
  4. All rights reserved 8-Feb-92, 13-Jun-92, 20-Aug-92, 23-Jul-92, 16-Aug-94
  5.  
  6. This unit may be used and distributed freely for PRIVATE, NON-COMMERCIAL,
  7. NON-INSTITUTIONAL purposes, provided it is not changed in any way, and
  8. that a proper attribution is made. For ANY other usage, such as use in a
  9. business enterprise or at a university, contact the author for the terms
  10. of registration.
  11.  
  12. The units are under development. Comments and contacts are solicited. If
  13. you have any questions, please do not hesitate to use electronic mail for
  14. communication.
  15. InterNet address: ts@uwasa.fi
  16.  
  17. The author shall not be liable to the user for any direct, indirect or
  18. consequential loss arising from the use of, or inability to use, any unit,
  19. program or file howsoever caused. No warranty is given that the units and
  20. programs will work under all circumstances.
  21.  
  22. Timo Salmi
  23. Professor of Accounting and Business Finance
  24. Faculty of Accounting & Industrial Management; University of Vaasa
  25. P.O. BOX 297, FIN-65101 Vaasa, Finland
  26.  
  27. Added 13-Jun-92
  28.  SETENVSH
  29. *)
  30.  
  31. unit TSUNTENV;
  32.  
  33. (* ======================================================================= *)
  34.                           interface
  35. (* ======================================================================= *)
  36.  
  37. uses Dos
  38.      {$IFDEF VER40}
  39.      ,TSUNT45
  40.      {$ENDIF}
  41.      ;
  42.  
  43. (* Get the size of the parent environment. Draws very heavily on the
  44.    article in the PC Magazine Vol. 11, No. 1, pp. 425-427, but also
  45.    includes some programming of my own *)
  46. function ENVSIZFN : word;
  47.  
  48. (* Get the size of the parent environment that is already used up.
  49.    This part of the environment code is primarily due to yours
  50.    truly, and is based on the format of the environment table which
  51.    is name=value1<nul>name=value2<nul>...name=valueN<nul><nul> *)
  52. function ENVUSEFN : word;
  53.  
  54. (* Get the starting segment address of the parent environment. Draws very
  55.    heavily on the article in the PC Magazine Vol. 11, No. 1, p. 425-427,
  56.    but also includes some ideas of my own.
  57.    Returns 0 if the address cannot be found *)
  58. function ENVADDFN : word;
  59.  
  60. (* Set the value of an environment variable. Note that the name of
  61.    the environment variable is CASE SENSITIVE. E.g. you can put
  62.    both COMSPEC and comspec in your environment.  (Don't.)
  63.    Use upper case throughout to be on the safe side.
  64.    This part of the environment code is solely my own (un)doing.
  65.    Status values:
  66.     0 = No errors detected
  67.     1 = Syntax error (Correct syntax: VARIABLE=VALUE)
  68.     2 = Out of environment space
  69.     3 = Missed the variable or the environment
  70.    Note that this takes effect only after the program has terminated!
  71.    Also note that any trailing white spaces are included:
  72.    'VARIABLE=VALUE' and 'VARIABLE = VALUE' are not the same thing.
  73. *)
  74. procedure SETENV (EnvVar : string; var status : byte);
  75.  
  76. (* Write the parent environment table on stdout *)
  77. procedure SHOWENV;
  78.  
  79. (* Set a temporary value for an environment variable.
  80.    SETENVSH should take effect for the duration of shelling to dos.
  81.    This was a complicated task with parts of code scraped from
  82.    here and there so be a bit wary.
  83.    Everything is made upper case.
  84.    Note the slightly differing syntax from SETENV.
  85. *)
  86. procedure SETENVSH (envvar, envval : string);
  87.  
  88.